@extends('layouts/admin')
    @section('content')
        <!--面包屑导航 开始-->
        <div class="crumb_warp">
            <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
            <i class="fa fa-home"></i> <a href="{{url('admin/info')}}">首页</a> &raquo; 文章管理
        </div>
        <!--面包屑导航 结束-->
        <!--结果集标题与导航组件 开始-->
        <div class="result_wrap">
            <div class="result_title">
                <h3>文章列表</h3>
            </div>
            <div class="result_content">
                <div class="short_wrap">
                    <a href="{{url('admin/article/create')}}"><i class="fa fa-plus"></i>添加文章</a>
                    <a href="{{url('admin/article')}}"><i class="fa fa-fw fa-list-ul"></i>全部文章</a>
                </div>
            </div>
        </div>
        <!--结果集标题与导航组件 结束-->
        @if(session('success'))
        <div class="result_title">
                <div class="mark" style="background-color: #66CC99;">
                    <p style="color: green;">{{session('success')}}</p>
                </div>
        </div>
        @endif
        <!--搜索结果页面 列表 开始-->
        <form action="#" method="post">
            <div class="result_wrap">
                <div class="result_content">
                    <table class="list_tab">
                        <tr>
                            <th class="tc">ID</th>
                            <th width="100" class="tc">缩略图</th>
                            <th>标题</th>
                            <th class="tc">作者</th>
                            <th class="tc">发布时间</th>
                            <th class="tc">查看次数</th>
                            <th class="tc">所属分类</th>
                            <th class="tc">操作</th>
                        </tr>
                        @foreach($data as $article)
                            <tr>
                                <td class="tc">{{$article->art_id}}</td>
                                <td width="80" class="tc">
                                    <img style="width: 50px;margin-bottom: -10px;"  src="{{asset($article->art_thumb)}}" alt="找不到了">
                                </td>
                                <td>
                                    <a href="#">{{$article->art_title}}</a>
                                </td>
                                <td class="tc">{{$article->art_editor}}</td>
                                <td class="tc">{{date('Y-m-d H:i:s',$article->art_time)}}</td>
                                <td class="tc">{{$article->art_view}}</td>
                                <td class="tc">{{$article->cate_id}}</td>
                                <td>
                                    <a href="{{url('admin/article/'.$article->art_id.'/edit')}}">修改</a>
                                    <a href="javascript:" onclick="return delarticle({{$article->art_id}})">删除</a>
                                </td>
                            </tr>
                        @endforeach
                        
                    </table>


                    <style type="text/css">
                        .result_content ul li span {
                            font-size: 15px;
                            padding: 6px 12px;
                        }

                    </style>

                    <div class="page_list">
                        {{$data->links()}}
                    </div>
                </div>
            </div>
        </form>
        <!--搜索结果页面 列表 结束-->
        <script type="text/javascript">
            // 异步更新排序
            function changeOrder(obj,article_id){
                var article_order = $(obj).val();
                $.post("{{url('admin/article/changeorder')}}", 
                    {'_token': '{{csrf_token()}}', 'article_id': article_id, 'article_order': article_order }, 
                    function ($data) {
                        if ($data['status'] === '1' ) {
                            layer.msg($data['msg']);
                        } else {
                            layer.msg($data['msg'], {icon: 5});
                        }
                    });
            }
            function delarticle(art_id){
                layer.confirm('确定删除吗？', {
                  btn: ['确定','取消'] //按钮
                }, function(){
                  $.post("{{url('admin/article/')}}/"+art_id,{'_token': "{{csrf_token()}}", '_method': 'delete' }, function (data) {
                        if(data.status == 1){
                            layer.msg(data.msg, {icon: 6});
                            setTimeout(function () {
                                location.href = location.href;
                            }, 1000);
                        }else{
                            layer.msg(data.msg, {icon: 5});
                            setTimeout(function () {
                                location.href = location.href;
                            }, 1000);
                        }
                  });
                }, function(){
                    
                });
            }
        </script>
    @stop
